# Maintainer:
# Contributor: Florian Klink <flokli at flokli dot de>

pkgname=python-pystache
_pkgname=pystache
pkgver=0.6.1
pkgrel=2
pkgdesc='The mustache template engine written in python'
arch=(any)
url='https://github.com/PennyDreadfulMTG/pystache'
license=('MIT')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
source=("https://github.com/PennyDreadfulMTG/$_pkgname/archive/v$pkgver/$_pkgname-$pkgver.tar.gz")
sha512sums=('516d286f84d2c77650550365f6b219acb712376f0b7302fff2aba7dee4d64e3d3fc2d781782777dd37093f6debf52f9d2a40b6ed8b65aa5f7025ff762cb5efae')

build() {
  cd "$_pkgname-$pkgver"
  python -m build --wheel --no-isolation
}

check() {
  cd "$_pkgname-$pkgver"
  # This package uses 2to3 to convert itself to Python 3 on the fly
  # So we need to jump through some hoops here
  test_dir="../test_dir"
  rm -rf "$test_dir"
  mkdir "$test_dir"
  python -m installer --destdir="$test_dir" dist/*.whl
  PYTHONPATH=$(readlink -e "$test_dir"/usr/lib/python*/site-packages/) \
  	"$test_dir"/usr/bin/pystache-test .
}

package() {
  cd "$_pkgname-$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}
